//账单方式
function changgeMail() {
	if (document.forms[0].BILL_TYPE.value == 1) {
		document.getElementById("e1").style.display = "inline-block";
		document.getElementById("e2").style.display = "inline-block";
		document.getElementById("e3").style.display = "inline-block";
		document.getElementById("e4").style.display = "inline-block";
		document.getElementById("e5").style.display = "inline-block";
	} else {
		document.getElementById("e1").style.display = "none";
		document.getElementById("e2").style.display = "none";
		document.getElementById("e3").style.display = "none";
		document.getElementById("e4").style.display = "none";
		document.getElementById("e5").style.display = "none";
	}
}
//发卡权
function changefk() {
	if (document.forms[0].ISSUING_AUTHORITY.value == 1
			|| document.forms[0].ISSUING_AUTHORITY.value == "") {
		document.getElementById("dd1").style.display = "none";
		document.getElementById("dd2").style.display = "none";
		document.getElementById("dd4").style.display = "none";
	} else {
		document.getElementById("dd1").style.display = "inline-block";
		document.getElementById("dd2").style.display = "inline-block";
		document.getElementById("dd4").style.display = "inline-block";
	}
}

//发卡按张
function getCardZ() {
	document.getElementById("CARD_FEE").readOnly = false;
	document.getElementById("CARD_FEE_PERCENTAGE").value = "";
	document.getElementById("CARD_FEE_PERCENTAGE").readOnly = true;
}
//发卡按百分比
function getCardB() {
	document.getElementById("CARD_FEE").readOnly = true;
	document.getElementById("CARD_FEE_PERCENTAGE").readOnly = false;
	document.getElementById("CARD_FEE").value = "";
}

//协议约定发卡按张
function getCardXYZ() {
	document.getElementById("CARDFEE_ONE").readOnly = false;
	document.getElementById("CARDFEE_TWO").value = "";
	document.getElementById("CARDFEE_TWO").readOnly = true;
}
//协议约定发卡按百分比
function getCardXYB() {
	document.getElementById("CARDFEE_ONE").readOnly = true;
	document.getElementById("CARDFEE_TWO").readOnly = false;
	document.getElementById("CARDFEE_ONE").value = "";
}
//是否发卡
function changeKFK() {
	if (document.forms[0].MANYTOONE.value == "2") {
		document.getElementById("ts1").style.display = "inline-block";
	} else {
		document.getElementById("ts1").style.display = "none";
	}
}
//是否收卡
function changeKSK() {
	if (document.forms[0].ONETOMANY.value == "2") {
		document.getElementById("ts2").style.display = "inline-block";
	} else {
		document.getElementById("ts2").style.display = "none";
	}
}
//票据类型
function changePj() {
	if (document.forms[0].INVOICE_TYPE.value == "2") {
		document.getElementById("pj2").style.display = "inline-block";
		document.getElementById("pj1").style.display = "none";
	} else if (document.forms[0].INVOICE_TYPE.value == "1") {
		document.getElementById("pj2").style.display = "none";
		document.getElementById("pj1").style.display = "inline-block";
	} else {
		document.getElementById("pj2").style.display = "none";
		document.getElementById("pj1").style.display = "none";
	}
}
//退货押金
function changetuihuo() {
	if (document.forms[0].RETURN_DEPOSIT.value == 1) {
		document.getElementById("tuihuo").style.display = "inline-block";
	} else {
		document.getElementById("tuihuo").style.display = "none";
	}
}
//保证金
function changeBzj() {
	if (document.forms[0].GUARANTEE.value == 2) {
		document.getElementById("bzj").style.display = "inline-block";
	} else {
		document.getElementById("bzj").style.display = "none";
	}
}
//几方协议
function changeXieyi() {
	if (document.forms[0].AGREEMENT_TYPE.value == "3") {
		document.getElementById("xieyi1").style.display = "inline-block";
		document.getElementById("xieyi2").style.display = "inline-block";
	} else {
		document.getElementById("xieyi1").style.display = "none";
		document.getElementById("xieyi2").style.display = "none";
	}
}

//判断是否有协议约定其他条款
function changeYueDing() {
	if (document.forms[0].CONTRACT_FLAG.value == "2") {
		document.getElementById("tableAgree").style.display = "inline-block";
		document.getElementById("tableAgree1").style.display = "inline-block";
		document.getElementById("tableAgree2").style.display = "inline-block";
		document.getElementById("tableAgree3").style.display = "inline-block";
		document.getElementById("tableAgree4").style.display = "inline-block";
		document.getElementById("tableAgree5").style.display = "inline-block";
	} else {
		document.getElementById("tableAgree").style.display = "none";
		document.getElementById("tableAgree1").style.display = "none";
		document.getElementById("tableAgree2").style.display = "none";
		document.getElementById("tableAgree3").style.display = "none";
		document.getElementById("tableAgree4").style.display = "none";
		document.getElementById("tableAgree5").style.display = "none";
	}
}

//开始金额与终止金额相等
function changeXYJE1() {
	document.getElementById("CONTRACT_AMOUNT_THREE").value = document
			.getElementById("CONTRACT_AMOUNT_TWO").value;
}
function changeXYJE2() {
	document.getElementById("CONTRACT_AMOUNT_TWO").value = document
			.getElementById("CONTRACT_AMOUNT_THREE").value;
}
function changeXYJE3() {
	document.getElementById("CONTRACT_AMOUNT_FIVE").value = document
			.getElementById("CONTRACT_AMOUNT_FOUR").value;
}
function changeXYJE4() {
	document.getElementById("CONTRACT_AMOUNT_FOUR").value = document
			.getElementById("CONTRACT_AMOUNT_FIVE").value;
}

//获取商户类别
function getValue() {
	var v = window.showModalDialog('basicActionTypeTree.action');
	if (v != null) {
		var arr = v.split(":");
		document.all.MERCH_TYPE.value = arr[0];
	}
}
//返回基本资料查询页面
function goBack() {
	document.all.SHOP_AC.value = "";
	document.all.MERCH_NAME.value = "";
	document.all.MERCH_ABBREVIATION.value = "";
	document.forms[0].action = "basicActionQuery.action";
	document.forms[0].submit();
}
function getZreaValue() {
	var v = window.showModalDialog('basicActionZreaTypeTree.action');
	if (v != null) {
		var arr = v.split(":");
		document.all.MERCH_AREA_ID.value = arr[0];
	}
}
function myZreaclear() {
	document.all.MERCH_AREA_ID.value = "";
}
//清除商户类别
function myclear() {
	document.all.MERCH_TYPE.value = "";
}
//获取复制的商户信息
function getAcctInfo() {
	var SHOP_AC = document.all.SHOP_AC.value;
	if (null == SHOP_AC || SHOP_AC.length == 0) {
		alert("请输入要复制的商户名称");
		return false;
	} else {
		$
				.post("basicActionCopyInfo.action",
						{
							//往action中传入参数
						SHOP_AC : $("#SHOP_AC").val()
					},
						function(returnedData, status) {
							if ("success" == status) {
								var id = $(returnedData).find("merchList")
										.text();
								var merchs = eval('(' + id + ')');
								var str = "<table id=chaxun width=100% align=left class=tablebox>";
								for ( var i = 0; i < merchs.length; i++) {
									str = str
											+ "<tr>"
											+ "<td>"
											+ merchs[i].mERCH_ID
											+ "</td>"
											+ "<td>"
											+ merchs[i].mERCH_NAME
											+ "</td>"
											+ "<td>"
											+ "<a href='basicActionCopyMerch.action?id="
											+ merchs[i].mERCH_ID + "'>基本</a>"
											+ "</td>" + "</tr>";

								}
								str = str + "<table>";
								document.getElementById("jsondiv").innerHTML = str;
								document.getElementById("fuzhi").style.display = "inline-block";
							}
						});
	}
}

//提交商户基本信息
$(document).ready(function() {
	//如果是必填的，则加红星标识.

		$("[class^='required']").each(function() {
			var $required = $("<strong class='high'> *</strong>"); //创建元素
				$(this).parent().append($required); //然后将它追加到文档中
			});
		$("[class^='{required']").each(function() {
			var $required = $("<strong class='high'> *</strong>"); //创建元素
				$(this).parent().append($required); //然后将它追加到文档中
			});
		$('#send').click(function() {
			var validator = $('#addForm').validate();
			if (validator.form()) {
				$("#addForm").submit();
			}
		});

	});